home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk10.zip / EATC.AWK < prev    next >
Text File  |  1991-10-05  |  506b  |  33 lines

  1.  
  2.  
  3. #  eatc.awk
  4. #  another program to remove comments
  5. #
  6.  
  7.  
  8. {  while( t = index($0 , "/*") )
  9.    {
  10.      printf "%s" , substr($0,1,t-1)
  11.      $0 = eat_comment( substr($0, t+2) )
  12.    }
  13.  
  14.    print 
  15. }
  16.  
  17.  
  18. function eat_comment(s,        t)
  19. {
  20.   #replace comment by one space
  21.   printf " "
  22.  
  23.   while ( (t = index(s, "*/")) == 0 )
  24.     if ( getline s == 0 )
  25.     { # input error -- unterminated comment
  26.           system("/bin/sh -c 'echo unterminated comment' 1>&2")
  27.       exit 1
  28.     }
  29.  
  30.   return  substr(s,t+2)
  31. }
  32.  
  33.